import java.util.Scanner;
public class Main {
    public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        Solution s=new Solution();

        System.out.println(s.reverse(a));
    }
}
class Solution {
    public int reverse(int x) {
        String a=x+"";
        String b="";
        for (int i = a.length()-1; i >=0; i--) {
            b+=a.charAt(i)+"";
        }

        if(b.endsWith("-")){
            b="-"+b.substring(0,b.length()-1);
        }
        try {
            if (Integer.parseInt(b) > Math.pow(2, 31) - 1 || Integer.parseInt(b) < -Math.pow(2, 31)) {
                return 0;
            }
        }catch (Exception e){
            return 0;
        }
        return Integer.parseInt(b);
    }
}